Socket
Socket
Sign inDemoInstall

@protobuf-ts/runtime-rpc

Package Overview
Dependencies
Maintainers
1
Versions
106
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@protobuf-ts/runtime-rpc

Runtime library for RPC clients generated by the protoc plugin "protobuf-ts"


Version published
Weekly downloads
270K
decreased by-7.74%
Maintainers
1
Weekly downloads
 
Created

What is @protobuf-ts/runtime-rpc?

@protobuf-ts/runtime-rpc is a TypeScript library that provides runtime support for Protocol Buffers (protobuf) and gRPC. It allows you to create and manage gRPC clients and servers, handle streaming, and perform unary calls with ease.

What are @protobuf-ts/runtime-rpc's main functionalities?

Unary Calls

This feature allows you to make unary gRPC calls. The code sample demonstrates how to set up a gRPC client and make a unary call to a service method.

const { GrpcWebFetchTransport } = require('@protobuf-ts/runtime-rpc');
const { MyServiceClient } = require('./my-service.client');

const transport = new GrpcWebFetchTransport({ baseUrl: 'http://localhost:8080' });
const client = new MyServiceClient(transport);

async function makeUnaryCall() {
  const response = await client.myUnaryMethod({ myField: 'myValue' });
  console.log(response);
}

makeUnaryCall();

Server Streaming

This feature allows you to handle server streaming gRPC calls. The code sample demonstrates how to set up a gRPC client and handle a server streaming method.

const { GrpcWebFetchTransport } = require('@protobuf-ts/runtime-rpc');
const { MyServiceClient } = require('./my-service.client');

const transport = new GrpcWebFetchTransport({ baseUrl: 'http://localhost:8080' });
const client = new MyServiceClient(transport);

async function handleServerStreaming() {
  const stream = client.myServerStreamingMethod({ myField: 'myValue' });
  for await (const response of stream.responses) {
    console.log(response);
  }
}

handleServerStreaming();

Client Streaming

This feature allows you to handle client streaming gRPC calls. The code sample demonstrates how to set up a gRPC client and handle a client streaming method.

const { GrpcWebFetchTransport } = require('@protobuf-ts/runtime-rpc');
const { MyServiceClient } = require('./my-service.client');

const transport = new GrpcWebFetchTransport({ baseUrl: 'http://localhost:8080' });
const client = new MyServiceClient(transport);

async function handleClientStreaming() {
  const stream = client.myClientStreamingMethod();
  stream.send({ myField: 'myValue1' });
  stream.send({ myField: 'myValue2' });
  stream.complete();
  const response = await stream.response;
  console.log(response);
}

handleClientStreaming();

Bidirectional Streaming

This feature allows you to handle bidirectional streaming gRPC calls. The code sample demonstrates how to set up a gRPC client and handle a bidirectional streaming method.

const { GrpcWebFetchTransport } = require('@protobuf-ts/runtime-rpc');
const { MyServiceClient } = require('./my-service.client');

const transport = new GrpcWebFetchTransport({ baseUrl: 'http://localhost:8080' });
const client = new MyServiceClient(transport);

async function handleBidirectionalStreaming() {
  const stream = client.myBidirectionalStreamingMethod();
  stream.send({ myField: 'myValue1' });
  stream.send({ myField: 'myValue2' });
  for await (const response of stream.responses) {
    console.log(response);
  }
}

handleBidirectionalStreaming();

Other packages similar to @protobuf-ts/runtime-rpc

Keywords

FAQs

Package last updated on 13 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc